import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '学/工号',
    align:"center",
    dataIndex: 'code',
    width:120
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name',
    width:120
   },
   
   {
    title: '部门',
    align:"center",
    dataIndex: 'departmentId_dictText',
    width:150
   },
   {
    title: '通行类型',
    align:"center",
    dataIndex: 'generalClassify',
    customRender: ({ text }) => {
      return render.renderDict(text, 'generalClassify');
    },
    width:100
   },
   {
    title: '离校方式',
    align:"center",
    dataIndex: 'leaveMode',
    customRender: ({ text }) => {
      return text==1?'家长接送':'自行离校';
    },
     width:150
   },
   {
    title: '原因',
    align:"center",
    dataIndex: 'reason',
     width:150
   },
   {
    title: '有效开始时间',
    align:"center",
    dataIndex: 'startDate',
     width:150
   },
   {
    title: '有效结束时间',
    align:"center",
    dataIndex: 'endDate',
     width:150
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status',
    customRender: ({ text }) => {
      return text==1?'生效中':'已失效';
    },
    width:100
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy',
    width:100
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createTime',
    width:150
   },
   
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "通行分类",
      field: 'generalClassify',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"generalClassify",
          stringToNumber: true,
      },
      //colProps: {span: 6},
 	},
  {
   label: '学/工号',
   field: 'code',
   component: 'Input',
  },
  {
   label: '姓名',
   field: 'name',
   component: 'Input',
  },
  {
    label: '所在部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps:{
      isRadioSelection:true,
      checkable:false,
      multiple:false,
    }
  },
];


export const accessRecordColumns:  BasicColumn[] = [
  {
    title: '学/工号',
    align:"center",
    dataIndex: 'personCode'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'personName'
   },
   {
    title: '刷卡方式',
    align:"center",
    dataIndex: 'accessMethod',
    customRender: ({ text }) => {
      return render.renderDict(text, 'accessMethod');
    },
   },
   {
    title: '刷卡卡号',
    align:"center",
    dataIndex: 'cardNo'
   },
   {
    title: '通行时间',
    align:"center",
    // sorter: true,
    dataIndex: 'accessDate'
   },
   {
    title: '抓拍图片',
    align:"center",
    // sorter: true,
    slots: { customRender: 'imgSlot' },
    dataIndex: 'snapLink'
   },
];
export const releaseformSchema: FormSchema[] = [
  {
   label: '通道',
   field: 'channelId',
   component: 'Input',
   slot:'channelSlot',
   dynamicRules: ({model,schema}) => {
    return [
           { required: true, message: '请选择通道!'},
    ];
  },
  },
  {
   label: '设备',
   field: 'deviceId',
   component: 'Input',
   slot:'deviceSlot',
   dynamicRules: ({model,schema}) => {
    return [
           { required: true, message: '请选择设备!'},
    ];
  },
  },
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show:false,
   },
];
export const accessRecordSearchFormSchema: FormSchema[] = [
  
]

//表单数据
export const tempPassformSchema: FormSchema[] = [
  {
    label: '类型',
    field: 'dataType',
    component: 'RadioButtonGroup',
    defaultValue: '1',
    componentProps: {
      options: [
        { label: '按部门', value: '1' },
        { label: '按人员', value: '2' },
      ],
    },
  },
  {
    label: '人员',
    field: 'personIds',
    component: 'JSelectPerson',
    componentProps: {
      labelKey: 'name',
    },
    // dynamicDisabled: ({ values }) => {
    //   return values.dataType==2;
    // },
    show: ({values})=>{
      return values.dataType==2;
    }
  },
  {
    label: '部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps: {
      multiple: false
      // labelKey: 'name',
    },
    // dynamicDisabled: ({ values }) => {
    //   return values.dataType==1;
    // },
    show: ({values})=>{
      return values.dataType==1;
    }
  },
  {
    label: '原因',
    field: 'reason',
    component: 'InputTextArea',
    // slot: 'JSelectAttendanceDev',
    componentProps: {
      labelKey: 'deviceName',
    },
  },
  {
    label: '离校方式',
    field: 'leaveMode',
    component: 'RadioGroup',
    defaultValue: '2',
    show:false,
    componentProps: {
      options: [
        { label: '家长接送', value: '1' },
        { label: '自行离校', value: '2' },
      ],
    },
  },
  {
    label: '开始时间',
    field: 'startDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required:  true},
    ]},
  },
  {
    label: '结束时间',
    field: 'endDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required:  true},
    ]},
  },
  {
    label: '类型',
    field: 'generalClassify',
    component: 'Input',
    show:false,
    defaultValue: 2
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];